package response

import (
	"net/http"

	"github.com/gin-gonic/gin"
)

type JsonResult struct {
	Code    int         `json:"code"`
	Message string      `json:"msg"`
	Error   string      `json:"error,omitempty"`
	Data    interface{} `json:"data"`
	Count   int64       `json:"count,omitempty"`
}

type AddressBookResult struct {
	UpdateAt string      `json:"update_at"`
	Data     interface{} `json:"data"`
	Error    bool        `json:"error,omitempty"`
}

func Result(code int, message string, data interface{}, count int64, ctx *gin.Context) {
	ctx.JSON(http.StatusOK, JsonResult{
		Code:    code,
		Message: message,
		Data:    data,
		Error:   message,
		Count:   count,
	})
}
